<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="../../lib/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="//at.alicdn.com/t/font_tnyc012u2rlwstt9.css" media="all"/>
    <link rel="stylesheet" href="../../common/css/user.css" media="all"/>
</head>
<!--下单-->

<body class="childrenBody">

<!--搜索栏-->
<blockquote class="layui-elem-quote news_search">

    <form class="layui-form" action="" lay-filter="example_query" id="formDom" style=" padding: 30px">

        <div class="layui-form-item">
            <label class="layui-form-label">发货人名字</label>
            <div class="layui-input-block">
                <input type="text" name="sendName" lay-verify="required" lay-reqtext="不能为空！" placeholder="请输入"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">发货人手机号</label>
            <div class="layui-input-block">
                <input type="text" name="sendMobile" lay-verify="required" lay-reqtext="不能为空！" placeholder="请输入"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">发货地址</label>
            <div class="layui-input-block">
                <input type="text" name="sendAddress" lay-verify="required" lay-reqtext="不能为空！" placeholder="请输入"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">快件描述</label>
            <div class="layui-input-block">
                <input type="text" name="description" lay-verify="required" lay-reqtext="不能为空！" placeholder="请输入"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-block">
                <input type="text" name="remark" lay-verify="required" lay-reqtext="不能为空！" placeholder="请输入"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">收货人名字</label>
            <div class="layui-input-block">
                <input type="text" name="receiveName" lay-verify="required" lay-reqtext="不能为空！" placeholder="请输入"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">收货人手机号</label>
            <div class="layui-input-block">
                <input type="text" name="receiveMobile" lay-verify="required" lay-reqtext="不能为空！" placeholder="请输入"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">收货地址</label>
            <div class="layui-input-block">
                <input type="text" name="receiveAddress" lay-verify="required" lay-reqtext="不能为空！" placeholder="请输入"
                       autocomplete="off" class="layui-input">
            </div>
        </div>


        <div class="layui-form-item">
            <button class="layui-btn search_btn" type="reset" style="margin-left: 20px">重置</button>
            <a class="layui-btn layui-btn-normal add_btn" lay-submit="" lay-filter="add" style="margin-left: 20px">添加</a>
            <a class="layui-btn layui-btn-normal to-list"  lay-filter="list"  style="margin-left: 20px">寄件列表</a>
        </div>

    </form>

</blockquote>
<script type="text/javascript" src="../../lib/layui/layui.js"></script>
<script type="text/javascript" src="../../common/js/config.js"></script>

<script>
    layui.config({
        base: $config.resUrl + '/web/common/js/'//定义基目录
    }).extend({
        ajaxExtention: 'ajaxExtention',//加载自定义扩展，每个业务js都需要加载这个ajax扩展
        $tool: 'tool',
        $api: 'api'
    }).use(['laydate', 'form', 'layer', 'jquery', 'table', 'laypage', 'ajaxExtention', '$tool', '$api'], function () {

        var form = layui.form,
            layer = parent.layer === undefined ? layui.layer : parent.layer,
            $ = layui.jquery,
            laypage = layui.laypage,
            $tool = layui.$tool,
            laydate = layui.laydate,
            table = layui.table,
            $api = layui.$api;


        form.on("submit(add)", function (data) {
            add();
            return false;
        });

        $(".to-list").click(function () {
            window.location.href = 'ExpressDelivery.html';
        });


        function add(){
            form.verify();
            var data = form.val('example_query');
            $api.doPost('/expressDelivery/save', data, function (result) {
                if (result.code != 200) {
                    layer.msg(result.data, {time: 500});
                    return;
                }
                layer.closeAll();
                layer.msg("保存成功！", {time: 500});
                $('#formDom')[0].reset();
                window.location.href = 'ExpressDelivery.html';
            });
        }

    });
</script>
</body>

</html>